package sistemasdistribuidos;

import classesBase.Cliente;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import telasMensagem.Bloqueio;
import telasMensagem.Concluido;
import telasMensagem.SimNao;

public class CadastroCliente extends javax.swing.JDialog {

    static boolean fecha = false;
    public CadastroCliente(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jTextFieldCodigoCliente.setEditable(false);
        //Substituir pelo ultimo códio salvo no banco somando uma unidade
        jTextFieldCodigoCliente.setText("00001");
        
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja "
                        + "sair sem salvar o cadastro? Todos os dados inseridos "
                        + "serão perdidos!<html>", 13);
                sn.setLocationRelativeTo(null);
                sn.setVisible(true);
                if (fecha == true) {
                    dispose();
                }
            }
        }
        );
    }
    
    public static void fecharCliente(boolean b){
        fecha = b;
    }

    public static void limpar() {
        jTextFieldNome.setText(null);
        jFormattedTelefone.setText(null);
        jFormattedRG.setText(null);
        jFormattedCelular.setText(null);
        jFormattedCPF.setText(null);
        jTextFieldEmail.setText(null);
        jTextPaneEndereco.setText(null);
        jTextPaneEndereco1.setText(null);
    }

    public void b(String msn) {
        Bloqueio b = new Bloqueio(null, true, msn);
        b.setLocationRelativeTo(null);
        b.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabelMsg13 = new javax.swing.JLabel();
        jTextFieldCodigoCliente = new javax.swing.JTextField();
        jLabelMsg3 = new javax.swing.JLabel();
        jTextFieldNome = new javax.swing.JTextField();
        jLabelMsg4 = new javax.swing.JLabel();
        jFormattedTelefone = new javax.swing.JFormattedTextField();
        jFormattedCelular = new javax.swing.JFormattedTextField();
        jLabelMsg5 = new javax.swing.JLabel();
        jFormattedCPF = new javax.swing.JFormattedTextField();
        jFormattedRG = new javax.swing.JFormattedTextField();
        jLabelMsg7 = new javax.swing.JLabel();
        jLabelMsg8 = new javax.swing.JLabel();
        jLabelMsg10 = new javax.swing.JLabel();
        jTextFieldEmail = new javax.swing.JTextField();
        jLabelMsg14 = new javax.swing.JLabel();
        jLabelMsg6 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextPaneEndereco = new javax.swing.JTextPane();
        jButtonSalvarCadastro = new javax.swing.JButton();
        jButtonLimparDados = new javax.swing.JButton();
        jLabelMsg9 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextPaneEndereco1 = new javax.swing.JTextPane();
        jLabelMsg11 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastro de Clientes");

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg13.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg13.setText("Código do Cliente:");

        jTextFieldCodigoCliente.setEditable(false);
        jTextFieldCodigoCliente.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigoCliente.setToolTipText("Código gerado pelo sistema");
        jTextFieldCodigoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldCodigoClienteActionPerformed(evt);
            }
        });

        jLabelMsg3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg3.setText("Nome:");

        jTextFieldNome.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldNome.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextFieldNomeMouseClicked(evt);
            }
        });
        jTextFieldNome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldNomeActionPerformed(evt);
            }
        });

        jLabelMsg4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg4.setText("Telefone:");

        try {
            jFormattedTelefone.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedTelefone.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jFormattedTelefone.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedTelefoneActionPerformed(evt);
            }
        });

        try {
            jFormattedCelular.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)#####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedCelular.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jFormattedCelular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedCelularActionPerformed(evt);
            }
        });

        jLabelMsg5.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg5.setText("Celular:");

        try {
            jFormattedCPF.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedCPF.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jFormattedCPF.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedCPFActionPerformed(evt);
            }
        });

        try {
            jFormattedRG.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.###.###-#")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jFormattedRG.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jFormattedRG.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFormattedRGActionPerformed(evt);
            }
        });

        jLabelMsg7.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg7.setText("RG:");

        jLabelMsg8.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg8.setText("CPF:");

        jLabelMsg10.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg10.setText("E-mail:");

        jTextFieldEmail.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldEmailActionPerformed(evt);
            }
        });

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Cadastro de Clientes");

        jLabelMsg6.setFont(new java.awt.Font("Segoe UI", 1, 16)); // NOI18N
        jLabelMsg6.setText("Endereço:");

        jTextPaneEndereco.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jScrollPane1.setViewportView(jTextPaneEndereco);

        jButtonSalvarCadastro.setBackground(new java.awt.Color(255, 255, 255));
        jButtonSalvarCadastro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonSalvarCadastro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonSalvarCadastro.setText("Salvar Cadastro");
        jButtonSalvarCadastro.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonSalvarCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarCadastroActionPerformed(evt);
            }
        });

        jButtonLimparDados.setBackground(new java.awt.Color(255, 255, 255));
        jButtonLimparDados.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonLimparDados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/limpar.png"))); // NOI18N
        jButtonLimparDados.setText("Limpar Dados");
        jButtonLimparDados.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonLimparDados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimparDadosActionPerformed(evt);
            }
        });

        jLabelMsg9.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
        jLabelMsg9.setText("Endereço 2:");

        jTextPaneEndereco1.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jScrollPane2.setViewportView(jTextPaneEndereco1);

        jLabelMsg11.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/cadastroAnimal.png"))); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jButtonSalvarCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButtonLimparDados)
                .addGap(140, 140, 140))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap(19, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabelMsg13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jTextFieldCodigoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabelMsg9)
                                    .addComponent(jLabelMsg6, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 514, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 514, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabelMsg3)
                                    .addGap(31, 31, 31)
                                    .addComponent(jTextFieldNome))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLabelMsg10)
                                            .addGap(29, 29, 29)
                                            .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLabelMsg5)
                                                    .addGap(23, 23, 23))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addComponent(jLabelMsg4)
                                                    .addGap(7, 7, 7)))
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jFormattedCelular, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
                                                .addComponent(jFormattedTelefone))
                                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addGap(79, 79, 79)
                                                    .addComponent(jFormattedRG, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addGap(28, 28, 28)
                                                    .addComponent(jLabelMsg7))
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                                    .addGap(25, 25, 25)
                                                    .addComponent(jLabelMsg8)
                                                    .addGap(19, 19, 19)
                                                    .addComponent(jFormattedCPF, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jLabelMsg11)))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(150, 150, 150)
                        .addComponent(jLabelMsg14)))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg13)
                    .addComponent(jTextFieldCodigoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelMsg3))
                .addGap(14, 14, 14)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg7)
                            .addComponent(jFormattedRG, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabelMsg4)
                                .addComponent(jFormattedTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jFormattedCPF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg8)
                            .addComponent(jFormattedCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg5))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg10)
                            .addComponent(jTextFieldEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabelMsg11))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabelMsg6)
                        .addGap(15, 15, 15)))
                .addGap(17, 17, 17)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(17, 17, 17)
                        .addComponent(jLabelMsg9)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jButtonLimparDados)
                    .addComponent(jButtonSalvarCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldNomeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextFieldNomeMouseClicked
        jTextFieldNome.setText(null);
    }//GEN-LAST:event_jTextFieldNomeMouseClicked

    private void jFormattedTelefoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedTelefoneActionPerformed

    }//GEN-LAST:event_jFormattedTelefoneActionPerformed

    private void jFormattedCelularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedCelularActionPerformed

    }//GEN-LAST:event_jFormattedCelularActionPerformed

    private void jFormattedCPFActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedCPFActionPerformed

    }//GEN-LAST:event_jFormattedCPFActionPerformed

    private void jFormattedRGActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFormattedRGActionPerformed

    }//GEN-LAST:event_jFormattedRGActionPerformed

    private void jTextFieldEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldEmailActionPerformed

    }//GEN-LAST:event_jTextFieldEmailActionPerformed

    private void jButtonSalvarCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarCadastroActionPerformed
        Cliente cli = new Cliente();

        cli.setId(Integer.parseInt(jTextFieldCodigoCliente.getText()));
        cli.setNome(jTextFieldNome.getText());
        cli.setTelefone(jFormattedTelefone.getText());
        cli.setRg(jFormattedRG.getText());
        cli.setCelular(jFormattedCelular.getText());
        cli.setCpf(jFormattedCPF.getText());
        cli.setEmail(jTextFieldEmail.getText());
        cli.setEndereco(jTextPaneEndereco.getText());
        cli.setEndereco2(jTextPaneEndereco1.getText());

        if (cli.getNome().length() == 0) {
            b("<html>Nenhum nome inserido no cadastro! <br>"
                    + "Por favor, informe o nome do cliente antes"
                    + " de prosseguir com o cadastro!</html>");
        } else {
            
            if (cli.getTelefone().equals("(  )    -    ")) {
                b("<html> Nenhum número de telefone inserido! <br>"
                        + "Por favor, informe corretamente o telefone do cliente antes"
                        + " de prosseguir com o cadastro!</html>");
            } else {
                if (cli.getEndereco().length() == 0) {
                    b("<html>Nenhum endereço especificado! <br>"
                            + "Por favor, informe o endereço do cliente antes"
                            + " de prosseguir com o cadastro!</html>");
                } else {
                    /*
                    
                     Salvar no banco de dados
                    
                     */
                    limpar();
                    Concluido co = new Concluido(null, true, "<html>O cadastro "
                            + "do cliente foi salvo com sucesso! <br>"
                            + "Para consultá-lo vá até a tela de Clientes Cadastrados.</html>");
                    co.setLocationRelativeTo(null);
                    co.setVisible(true);
                }
            }
        }
    }//GEN-LAST:event_jButtonSalvarCadastroActionPerformed

    private void jButtonLimparDadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimparDadosActionPerformed
        SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja"
                + " limpar todos os dados inseridos nos campos?</html>", 6);
        sn.setLocationRelativeTo(null);
        sn.setVisible(true);
    }//GEN-LAST:event_jButtonLimparDadosActionPerformed

    private void jTextFieldCodigoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldCodigoClienteActionPerformed
        
    }//GEN-LAST:event_jTextFieldCodigoClienteActionPerformed

    private void jTextFieldNomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldNomeActionPerformed
        
    }//GEN-LAST:event_jTextFieldNomeActionPerformed

    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroCliente.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                CadastroCliente dialog = new CadastroCliente(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonLimparDados;
    private javax.swing.JButton jButtonSalvarCadastro;
    public static javax.swing.JFormattedTextField jFormattedCPF;
    public static javax.swing.JFormattedTextField jFormattedCelular;
    public static javax.swing.JFormattedTextField jFormattedRG;
    public static javax.swing.JFormattedTextField jFormattedTelefone;
    private javax.swing.JLabel jLabelMsg10;
    private javax.swing.JLabel jLabelMsg11;
    private javax.swing.JLabel jLabelMsg13;
    private javax.swing.JLabel jLabelMsg14;
    private javax.swing.JLabel jLabelMsg3;
    private javax.swing.JLabel jLabelMsg4;
    private javax.swing.JLabel jLabelMsg5;
    private javax.swing.JLabel jLabelMsg6;
    private javax.swing.JLabel jLabelMsg7;
    private javax.swing.JLabel jLabelMsg8;
    private javax.swing.JLabel jLabelMsg9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    public static javax.swing.JTextField jTextFieldCodigoCliente;
    public static javax.swing.JTextField jTextFieldEmail;
    public static javax.swing.JTextField jTextFieldNome;
    public static javax.swing.JTextPane jTextPaneEndereco;
    public static javax.swing.JTextPane jTextPaneEndereco1;
    // End of variables declaration//GEN-END:variables
}
